/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#include "UGame/Util/String.h"
#include <cstdio>
#include <cstring>

namespace UGame {
namespace Util {

    int vsnprintf(char *_Dest, int _Size, const char *_Format, std::va_list _Args)
    {
        return ::vsnprintf(_Dest, _Size, _Format, _Args);
    }

    int vfprintf(FILE * _File, const char * _Format, std::va_list _Args)
    {
        return ::vfprintf(_File, _Format, _Args);
    }

    char *itoa(int _Val, char *_Buf, std::size_t _Size, int _Radix)
    {
    	const char* _Format = NULL;
    	switch(_Radix) {
    	case 10:
    		_Format = "%d";
    		break;
    	case 16:
    		_Format = "%x";
    		break;
    	}
    	sprintf(_Buf, _Format, _Val);
        return _Buf;
    }

    char *ltoa(long _Val, char *_Buf, std::size_t _Size, int _Radix)
    {
    	const char* _Format = NULL;
    	switch(_Radix) {
    	case 10:
    		_Format = "%ld";
    		break;
    	case 16:
    		_Format = "%x";
    		break;
    	}
    	sprintf(_Buf, _Format, _Val);
    	return _Buf;
    }

    int strcasecmp(const char* _Str1, const char* _Str2)
    {
        return ::strcasecmp(_Str1, _Str2);
    }
}}
